﻿using System;
using System.IO;
using SEXY;
using UnityEngine;

namespace Studio
{
	// Token: 0x020004AB RID: 1195
	[Serializable]
	public class HSColorSet
	{
		// Token: 0x17000334 RID: 820
		// (get) Token: 0x06001DEA RID: 7658 RVA: 0x000BDC08 File Offset: 0x000BBE08
		public Color rgbaDiffuse
		{
			get
			{
				return HsvColor.ToRgba(this.hsvDiffuse, this.alpha);
			}
		}

		// Token: 0x17000335 RID: 821
		// (get) Token: 0x06001DEB RID: 7659 RVA: 0x000BDC1C File Offset: 0x000BBE1C
		public Color rgbDiffuse
		{
			get
			{
				return HsvColor.ToRgb(this.hsvDiffuse);
			}
		}

		// Token: 0x17000336 RID: 822
		// (get) Token: 0x06001DEC RID: 7660 RVA: 0x000BDC2C File Offset: 0x000BBE2C
		public Color rgbSpecular
		{
			get
			{
				return HsvColor.ToRgb(this.hsvSpecular);
			}
		}

		// Token: 0x06001DED RID: 7661 RVA: 0x000BDC3C File Offset: 0x000BBE3C
		public static bool CheckSameColor(HSColorSet a, HSColorSet b, bool hsv, bool alpha, bool specular)
		{
			if (alpha && a.alpha != b.alpha)
			{
				return false;
			}
			if (hsv && (a.hsvDiffuse.H != b.hsvDiffuse.H || a.hsvDiffuse.S != b.hsvDiffuse.S || a.hsvDiffuse.V != b.hsvDiffuse.V))
			{
				return false;
			}
			if (specular)
			{
				if (a.specularIntensity != b.specularIntensity)
				{
					return false;
				}
				if (a.specularSharpness != b.specularSharpness)
				{
					return false;
				}
				if (a.hsvSpecular.H != b.hsvSpecular.H || a.hsvSpecular.S != b.hsvSpecular.S || a.hsvSpecular.V != b.hsvSpecular.V)
				{
					return false;
				}
			}
			return true;
		}

		// Token: 0x06001DEE RID: 7662 RVA: 0x000BDD3C File Offset: 0x000BBF3C
		public void SetDiffuseRGBA(Color rgba)
		{
			this.hsvDiffuse = HsvColor.FromRgb(rgba);
			this.alpha = rgba.a;
		}

		// Token: 0x06001DEF RID: 7663 RVA: 0x000BDD58 File Offset: 0x000BBF58
		public void SetDiffuseRGB(Color rgb)
		{
			this.hsvDiffuse = HsvColor.FromRgb(rgb);
			this.alpha = 1f;
		}

		// Token: 0x06001DF0 RID: 7664 RVA: 0x000BDD74 File Offset: 0x000BBF74
		public void SetSpecularRGB(Color rgb)
		{
			this.hsvSpecular = HsvColor.FromRgb(rgb);
		}

		// Token: 0x06001DF1 RID: 7665 RVA: 0x000BDD84 File Offset: 0x000BBF84
		public void Copy(HSColorSet src)
		{
			this.hsvDiffuse = new HsvColor(src.hsvDiffuse.H, src.hsvDiffuse.S, src.hsvDiffuse.V);
			this.alpha = src.alpha;
			this.hsvSpecular = new HsvColor(src.hsvSpecular.H, src.hsvSpecular.S, src.hsvSpecular.V);
			this.specularIntensity = src.specularIntensity;
			this.specularSharpness = src.specularSharpness;
		}

		// Token: 0x06001DF2 RID: 7666 RVA: 0x000BDE10 File Offset: 0x000BC010
		public void BlendHSV(HSColorSet c01, HSColorSet c02, float rate)
		{
			this.hsvDiffuse = new HsvColor(Mathf.Lerp(c01.hsvDiffuse.H, c02.hsvDiffuse.H, rate), Mathf.Lerp(c01.hsvDiffuse.S, c02.hsvDiffuse.S, rate), Mathf.Lerp(c01.hsvDiffuse.V, c02.hsvDiffuse.V, rate));
			this.alpha = Mathf.Lerp(c01.alpha, c02.alpha, rate);
			this.hsvSpecular = new HsvColor(Mathf.Lerp(c01.hsvSpecular.H, c02.hsvSpecular.H, rate), Mathf.Lerp(c01.hsvSpecular.S, c02.hsvSpecular.S, rate), Mathf.Lerp(c01.hsvSpecular.V, c02.hsvSpecular.V, rate));
			this.specularIntensity = Mathf.Lerp(c01.specularIntensity, c02.specularIntensity, rate);
			this.specularSharpness = Mathf.Lerp(c01.specularSharpness, c02.specularSharpness, rate);
		}

		// Token: 0x06001DF3 RID: 7667 RVA: 0x000BDF24 File Offset: 0x000BC124
		public void BlendRGB(HSColorSet c01, HSColorSet c02, float rate)
		{
			Color color = HsvColor.ToRgb(c01.hsvDiffuse);
			Color color2 = HsvColor.ToRgb(c02.hsvDiffuse);
			Color rgb = new Color(Mathf.Lerp(color.r, color2.r, rate), Mathf.Lerp(color.g, color2.g, rate), Mathf.Lerp(color.b, color2.b, rate));
			this.hsvDiffuse = HsvColor.FromRgb(rgb);
			this.alpha = Mathf.Lerp(c01.alpha, c02.alpha, rate);
			color = HsvColor.ToRgb(c01.hsvSpecular);
			color2 = HsvColor.ToRgb(c02.hsvSpecular);
			rgb = new Color(Mathf.Lerp(color.r, color2.r, rate), Mathf.Lerp(color.g, color2.g, rate), Mathf.Lerp(color.b, color2.b, rate));
			this.hsvSpecular = HsvColor.FromRgb(rgb);
			this.specularIntensity = Mathf.Lerp(c01.specularIntensity, c02.specularIntensity, rate);
			this.specularSharpness = Mathf.Lerp(c01.specularSharpness, c02.specularSharpness, rate);
		}

		// Token: 0x06001DF4 RID: 7668 RVA: 0x000BE048 File Offset: 0x000BC248
		public void Save(BinaryWriter writer)
		{
			writer.Write((double)this.hsvDiffuse.H);
			writer.Write((double)this.hsvDiffuse.S);
			writer.Write((double)this.hsvDiffuse.V);
			writer.Write((double)this.alpha);
			writer.Write((double)this.hsvSpecular.H);
			writer.Write((double)this.hsvSpecular.S);
			writer.Write((double)this.hsvSpecular.V);
			writer.Write((double)this.specularIntensity);
			writer.Write((double)this.specularSharpness);
		}

		// Token: 0x06001DF5 RID: 7669 RVA: 0x000BE0E8 File Offset: 0x000BC2E8
		public void Load(BinaryReader reader, int version)
		{
			this.hsvDiffuse.H = (float)reader.ReadDouble();
			this.hsvDiffuse.S = (float)reader.ReadDouble();
			this.hsvDiffuse.V = (float)reader.ReadDouble();
			this.alpha = (float)reader.ReadDouble();
			this.hsvSpecular.H = (float)reader.ReadDouble();
			this.hsvSpecular.S = (float)reader.ReadDouble();
			this.hsvSpecular.V = (float)reader.ReadDouble();
			this.specularIntensity = (float)reader.ReadDouble();
			this.specularSharpness = (float)reader.ReadDouble();
		}

		// Token: 0x0400207A RID: 8314
		public const int SaveVersion = 1;

		// Token: 0x0400207B RID: 8315
		public HsvColor hsvDiffuse = new HsvColor(19f, 0.07f, 0.63f);

		// Token: 0x0400207C RID: 8316
		public float alpha = 1f;

		// Token: 0x0400207D RID: 8317
		public HsvColor hsvSpecular = new HsvColor(0f, 0f, 0.8f);

		// Token: 0x0400207E RID: 8318
		public float specularIntensity = 0.1f;

		// Token: 0x0400207F RID: 8319
		public float specularSharpness = 0.33f;
	}
}
